package com.homework.ch13;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

/**
 * @author yuxi
 * @version 1.0
 * @date 2025/10/21
 * @Description:
 */
public class Test1 {
    public static void main(String[] args) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
        List<Integer> list=new ArrayList<>();
        Class<? extends List> clazz=list.getClass();
        Method method=clazz.getDeclaredMethod("add", Object.class);
        method.invoke(list, "hello");
        method.invoke(list, 123);
        method.invoke(list, 3.14);
        System.out.println(list);

    }
}
